//
//  ZZTaskTypeNameAddVC.swift
//  QMXK
//
//  Created by jenkin on 2018/12/11.
//  Copyright © 2018年 jenkin. All rights reserved.
//

import UIKit

class ZZTaskTypeNameAddVC: ZZBaseVC {

    var clickSaveBlock:ClickSaveBlock?
    lazy var nameTextField:UITextField = {
       return UITextField.init()
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.setUI()
    }

    override func setUI() {
        
        super.setUI()
        
        self.view.addSubview(self.nameTextField)
        self.nameTextField.placeholder = "请输入名称"
        self.nameTextField.backgroundColor = UIColor.white
        self.nameTextField.snp.makeConstraints { (make) in
            make.width.equalTo(100)
            make.height.equalTo(30)
            make.center.equalTo(self.view)
        }
        
        let saveBtn:UIButton = UIButton.init()
        saveBtn.addTarget(self, action: #selector(completeAction(sender:)), for: UIControl.Event.touchUpInside)
        saveBtn.setTitle("完成", for: UIControl.State.normal)
        saveBtn.backgroundColor = ColorConst.shareColorConst.mainTintColor()
        self.view.addSubview(saveBtn)
        saveBtn.snp.makeConstraints { (make) in
            make.centerX.equalTo(self.view)
            make.width.equalTo(100)
            make.height.equalTo(30)
            make.top.equalTo(self.nameTextField.snp.bottom).offset(50)
        }
    }
    
    @objc func completeAction(sender:UIButton){
        if self.clickSaveBlock != nil{
            self.clickSaveBlock!(["name":self.nameTextField.text])
            self.navigationController?.popViewController(animated: true)
        }
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.view.endEditing(true)
    }
}
